package mobi.hami.huapin.dao;

import java.util.List;
import java.util.Map;

import mobi.hami.huapin.daobase.CrudMapper;
import mobi.hami.huapin.model.Product;
import mobi.hami.huapin.model.SpuSubjectMapping;
import mobi.hami.huapin.model.SpuSubjectMappingExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface SpuSubjectMappingMapper extends CrudMapper<SpuSubjectMapping> {
    /**
     * 多条件搜索-某个-主题下的商品
     * @param parms
     * @return
     */
    @SelectProvider(type = SpuSubjectMappingProvider.class,method = "subject_products")
    List<Product> subject_products(Map<String,Object> parms);

    /**
     * 主题管理-把某个商品从某个主题下删除
     * @param pid 商品id
     * @param subid 主题id
     * @param  deleted 删除状态，0表示正常，1表示已经删除
     * @return
     */
    @Update("update spu_subject_mapping set deleted = #{deleted} where spu_id = #{pid} and subject_id = #{subid}")
    int updatesmdelete(@Param("pid") Integer pid,@Param("subid") Integer subid,@Param("deleted") Integer deleted);

}